class Player(object):
    def __init__(self):
        self.food = 0
        self.reputation = 0

        self.firstround = True
        self.meanrep1 = 0.  # the last rep
        self.meanrep2 = 0.  # the last rep before the last one

    def _argsort(self, arr, asc=True):
        args = sorted(range(len(arr)), key=arr.__getitem__)
        if not asc:
            args.reverse()
        return args

    def hunt_choices(self, round_number, current_food, current_reputation, m,
                player_reputations):
        # Since it's likely that everyone will think it's a good idea to hunt
        # in the first round... slack 'em all
        if self.firstround:
            choices = ['s'] * len(player_reputations)
            self.firstround = False
            return choices

        P = len(player_reputations)

        # Compute current mean reputation
        meanrep = float(sum(player_reputations)) / P
        # Compute the trend over the two last rounds
        trend = meanrep - self.meanrep2

        choices = ['s'] * len(player_reputations)
        if trend > 0:
            # Get the most trustable players
            trustable = self._argsort(player_reputations, asc=False)
            for i in range(len(trustable) / 2):
                if player_reputations[trustable[i]] < 0.3:
                    break
                choices[trustable[i]] = 'h'

        # Refresh MeanReputation history
        self.meanrep2 = self.meanrep1
        self.meanrep1 = meanrep

        return choices

    def hunt_outcomes(self, food_earnings):
        pass

    def round_end(self, award, m, number_hunters):
        pass
